package com.gsit.expenditure.client.domina;



import com.gsit.expenditure.domain.Customer;
import com.gsit.expenditure.domain.OtherBill;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class OtherBillBean implements BeanHendler<OtherBill > {
	
	private ObjectProperty<Customer> customerName = new SimpleObjectProperty<Customer>();
	private StringProperty refNo = new SimpleStringProperty("");
	private StringProperty date = new SimpleStringProperty();
	private StringProperty description = new SimpleStringProperty("");
	private DoubleProperty amount = new SimpleDoubleProperty();
	
	private OtherBill otherBill;
	
	public OtherBillBean(OtherBill otherBill){
		
		if (otherBill==null) {
			otherBill=new OtherBill();
		}
		this.otherBill=otherBill;
		init(otherBill);
	}
	
	@Override
	public void init(OtherBill otherBill){
			refNo.setValue(otherBill.getReferenceNumber());
			description.setValue(otherBill.getDescription());
			amount.setValue(otherBill.getAmount());
	}

	@Override
	public void reLoad(OtherBill otherBill) {
		this.otherBill=otherBill;
		init(otherBill);
		clean();
		
	}

	@Override
	public void clean() {
		customerName.setValue(null);
		refNo.setValue("");
		date.setValue("");
		description.setValue("");
		amount.setValue(0.0);
	}

	@Override
	public OtherBill getObject() {
		
		otherBill.setCustomer(customerName.getValue());
		System.out.println("OtherBillBean-CustName>>>>>>>>>>>>>>"+customerName.getValue());
		otherBill.setReferenceNumber(refNo.getValue());
		otherBill.setDescription(description.getValue());
		otherBill.setAmount(amount.getValue());
		
		return otherBill;
	}
	
	public StringProperty getDate() {
		return date;
	}

	public void setDate(StringProperty date) {
		this.date = date;
	}
	

	public ObjectProperty<Customer> getCustomerName() {
		return customerName;
	}

	public void setCustomerName(ObjectProperty<Customer> customerName) {
		this.customerName = customerName;
	}

	public StringProperty getRefNo() {
		return refNo;
	}

	public void setRefNo(StringProperty refNo) {
		this.refNo = refNo;
	}


	public StringProperty getDescription() {
		return description;
	}

	public void setDescription(StringProperty description) {
		this.description = description;
	}

	public DoubleProperty getAmount() {
		return amount;
	}

	public void setAmount(DoubleProperty amount) {
		this.amount = amount;
	}

	public OtherBill getOtherBill() {
		return otherBill;
	}

	public void setOtherBill(OtherBill otherBill) {
		this.otherBill = otherBill;
	}
	
	
	

}
